<template>
  <div class="wrap">
    <el-dialog
      title="新增标签"
      :visible.sync="state"
      @close="close"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
    >
      <el-form>
        <el-form-item label="标签名:" :label-width="formLabelWidth">
          <el-input placeholder="请输入标签名" v-model="tagName"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="close()">取 消</el-button>
        <el-button type="primary" @click="close(1)">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
export default {
  props: {
    tagAddState: {
      type: Boolean,
      default: false
    }
  },
  computed: {
    state: {
      get() {
        this.tagName = "";
        return this.tagAddState;
      },
      set() {}
    }
  },
  data() {
    return {
      formLabelWidth: "140px",
      tagName: ""
    };
  },
  methods: {
    close(e) {
      console.log(e)
      if (e) {
        if (!this.tagName) {
          this.$alert("请输入标签名", "提示", {
            confirmButtonText: "确定"
          });
          return false;
        }
        this.$emit("tagMeth", { tagName: this.tagName });
      } else {
        this.$emit("tagMeth");
      }
    }
  }
};
</script>